var express=require('express');
var app = express();
var AAP = 0;
var puerto=process.argv[2]?process.argv[2]:8080;


app.get('/contador/html', function (req, res) {   
	var htm='<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Datos en HTML</title></head><body>';
	htm+='<p>Contador AAP: '+AAP+'</p>';
	res.send(htm+'</body></html>');
});

app.get('/contador/json', function (req, res) { 
	res.contentType('application/json');
	res.send(AAP);
});

app.post('/contador/incrementar/AAP', function (req, res) {   
    AAP++;
	res.contentType('application/json');
    res.send( AAP );
});
app.listen(puerto);
console.log('Server running at http://127.0.0.1:'+puerto+'/');